package com.itheima.tilas.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartFile;

/**
 * 使用@Bean注解,自动装配 阿里云Oss对象 ,实现阿里云对象的复用
 *
 * @author 132
 */
@Configuration
public class LoadOssConfig {
    @Resource
    AliyunOssConfig ossConfig;

    /**
     * 创建阿里云oss 连接信息OssBean
     * @return
     */
    @Bean("ossBean")
    public OSS createOss() {
        OSS build = new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(),
                ossConfig.getSecretAccessKey());
        return build;
    }
}
